package org.d7_buffered_stream;

import java.io.*;

/**
 * 目标：掌握字节缓冲流的作用
 * 对原始流进行包装，以提高原始流读写数据的功能
 */
public class BufferedInputStreamTest1 {
    public static void main(String[] args) throws IOException {
        try(
                InputStream is = new FileInputStream("D:\\idea\\idea code\\java-practice\\practice\\change\\file-oi-app\\src\\test\\d7test1.txt");
                //1。定义一个字节缓冲输入流包装原始的字节输入流
        InputStream bis = new BufferedInputStream(is);
                OutputStream os =  new FileOutputStream("D:\\idea\\idea code\\java-practice\\practice\\change\\file-oi-app\\src\\test\\d7test1new.txt");
                //2。定义一个字节缓冲输出流包装原始的字节输出流
               OutputStream bos =  new BufferedOutputStream(os);

        ) {

            byte[] buffer = new byte[1024];
            int len;
            while ((len = bis.read(buffer))!= -1){
                bos.write(buffer,0,len);
            }
            System.out.println("复制完成");
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
